home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / PowerPlant / Gadgets / CAboutDialog.cp < prev    next >
Encoding:
Text File  |  1996-03-19  |  3.3 KB  |  173 lines  |  [TEXT/CWIE]

  1. // CAboutDialog.cp -- dialog methods
  2. // Created 3/19/96 12:49 PM by AppMaker
  3.  
  4. #include "CAboutDialog.h"
  5.  
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LStdControl.h>
  10. #include <PP_Messages.h>
  11. #include "CmdCodes.h"
  12.  
  13. #define PPob_AboutDialogID    205
  14. #define RidL_AboutDialogID    205
  15.  
  16. Boolean        CAboutDialog::sIsRegistered = false;
  17.  
  18. //----------
  19. void
  20. CAboutDialog::RegisterClass ()
  21. {
  22.     URegistrar::RegisterClass ('Abog', (ClassCreatorFunc)CAboutDialog::CreateAboutDialogStream);
  23.  
  24.     // register the pane classes we use
  25.  
  26.     sIsRegistered = true;
  27. }
  28.  
  29. //----------
  30. CAboutDialog*
  31. CAboutDialog::CreateAboutDialog(
  32.     LCommander    *inSuperCommander)
  33. {
  34.     if (!sIsRegistered) {
  35.         RegisterClass ();
  36.     }
  37.     return ((CAboutDialog *)LWindow::CreateWindow(PPob_AboutDialogID, inSuperCommander));
  38. }
  39.  
  40. //----------
  41. //    This is the function you register with URegistrar to create a
  42. //    CAboutDialog from a resource
  43. CAboutDialog*
  44. CAboutDialog::CreateAboutDialogStream(
  45.     LStream    *inStream)
  46. {
  47.     return (new CAboutDialog(inStream));
  48. }
  49.  
  50. //----------
  51. //    The default constructor does nothing.
  52. CAboutDialog::CAboutDialog()
  53. {
  54. }
  55.  
  56. //----------
  57. //    The read-from-stream constructor just reads a dialog object.
  58. CAboutDialog::CAboutDialog(
  59.     LStream    *inStream)
  60.         : LDialogBox(inStream)
  61. {
  62. }
  63.  
  64. //----------
  65. //    The destructor does nothing.
  66. CAboutDialog::~CAboutDialog()
  67. {
  68. }
  69.  
  70. //----------
  71. //    This member function gets called once the containment hierarchy that contains
  72. //    this pane has been built. It gives us a chance to get data members for
  73. //    interesting subviews, and to do other operations now that our subviews exist.
  74. void
  75. CAboutDialog::FinishCreateSelf()
  76. {
  77.     LDialogBox::FinishCreateSelf();
  78.  
  79.     mOKButton = (LStdButton *)FindPaneByID ('OK  ');
  80.  
  81.     UReanimator::LinkListenerToControls(this, this, RidL_AboutDialogID);
  82.         // the purpose is to "connect" self to whatever controls
  83.         // that we want to "listen" to
  84.  
  85. // any additional initialization for your dialog:
  86.  
  87. }
  88.  
  89. //----------
  90. void
  91. CAboutDialog::ListenToMessage(
  92.     MessageT    inMessage,
  93.     void        *ioParam)
  94. {
  95.     switch (inMessage) {
  96.     case msg_OK:
  97.             GetSuperCommander()->ProcessCommand(cmd_AboutDialog, this);
  98.         break;
  99.  
  100.     case msg_Cancel:
  101.             DoClose();
  102.         break;
  103.  
  104.     default:
  105.         break;
  106.     }
  107. }
  108.  
  109. //----------
  110. Boolean
  111. CAboutDialog::ObeyCommand(
  112.     CommandT    inCommand,
  113.     void        *ioParam)
  114. {
  115.     Boolean        cmdHandled = true;
  116.  
  117.     switch (inCommand) {
  118.  
  119.     // +++ Add cases here for the commands you handle
  120.     //        Remember to add same cases to FindCommandStatus below
  121.     //        to enable/disable the commands
  122.  
  123.     default:
  124.             cmdHandled = LDialogBox::ObeyCommand(inCommand, ioParam);
  125.         break;
  126.     }
  127.  
  128.     return cmdHandled;
  129. }
  130.  
  131. //----------
  132. void
  133. CAboutDialog::FindCommandStatus(
  134.     CommandT    inCommand,
  135.     Boolean        &outEnabled,
  136.     Boolean        &outUsesMark,
  137.     Char16        &outMark,
  138.     Str255        outName)
  139. {
  140.     outUsesMark = false;
  141.  
  142.     switch (inCommand) {
  143.  
  144.     // +++ Add cases here for the commands you handle
  145.  
  146.     default:
  147.             LDialogBox::FindCommandStatus(inCommand, outEnabled,
  148.                                             outUsesMark, outMark, outName);
  149.         break;
  150.     }
  151. }
  152.  
  153. //----------
  154. Boolean
  155. CAboutDialog::FocusDraw()
  156. {
  157.     Boolean        focused = LView::FocusDraw();
  158.  
  159.     if (focused) {
  160.         AuxWinHandle    awHndl;
  161.         CTabHandle        awCTable;
  162.         ColorSpec        contentSpec;
  163.  
  164.         GetAuxWin(GetMacPort(), &awHndl);
  165.         awCTable = (**awHndl).awCTable;
  166.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  167.         ::RGBBackColor(&contentSpec.rgb);
  168.     }
  169.  
  170.     return focused;
  171. }
  172.  
  173.